package cn.com.servlet;

import cn.com.controller.*;
import cn.com.controller.administrator.ClaController;
import cn.com.controller.administrator.PerController;
import cn.com.controller.administrator.TaskController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>Project:AcademicSystem - AcademicServlet
 *
 * @author 黄俊玮 On Administrator
 * @version 1.0
 * @DataTime 2024/6/13 17:38:08
 * @since 1.8
 */
public class AcademicServlet extends HttpServlet {
   private ClaController classController = new ClaController();
   private LoginController loginController = new LoginController();
   private PerController perController = new PerController();
   private StuController stuController = new StuController();
   private TaskController taskController =new TaskController();
   private TeaController teaController = new TeaController();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String path = req.getServletPath();
        if ("/index.do".equals(path))req.getRequestDispatcher("/index.jsp").forward(req,resp);//登录界面
        else if ("/out.do".equals(path))out(resp);//处理限制页面
        else if ("/index/login.do".equals(path))loginController.goLogin(req, resp);//处理用户提交的登录信息
        else if ("/index/logout.do".equals(path))loginController.goLogout(req, resp);//处理用户提交的退出登录信息
        else if ("/student/update.do".equals(path)) stuController.doHome_one(req, resp);//跳转至学生更新页面
        else if ("/student/modifyNow.do".equals(path)) stuController.modifyNow(req, resp);//学生更新后台服务
        else if ("/student/show.do".equals(path)) stuController.doHome_two(req, resp);//跳转学生课室课程表
        else if ("/student/findScore.do".equals(path)) stuController.doHome_three(req, resp);//跳转至学生成绩查询
        else if ("/teacher/update.do".equals(path)) teaController.doHome_one(req, resp);//跳转至学生更新页面
        else if ("/teacher/modifyNow.do".equals(path)) teaController.modifyNow(req, resp);//教师更新后台服务
        else if ("/teacher/findClass.do".equals(path)) teaController.doHome_two(req, resp);//跳转至学生成绩查询
        else if ("/teacher/findClass/Score.do".equals(path)) teaController.Score(req, resp);//跳转学生成绩页面
        else if ("/teacher/findClass/updateScore.do".equals(path)) teaController.updateScores(req, resp);//学生成绩修改后台
        else if ("/Administrator/classManager.do".equals(path))classController.classManager(req, resp);//管理员班级管理页面
        else if ("/Administrator/classManager/updateClass.do".equals(path))classController.update(req, resp);//修改班级信息页面
        else if ("/Administrator/classManager/updateClass/modifyNow.do".equals(path))classController.modifyClassNow(req, resp);//修改班级信息后台
        else if ("/Administrator/classManager/deleteClass.do".equals(path))classController.deleteClass(req,resp);//删除班级信息后台
        else if ("/Administrator/classManager/addClass.do".equals(path))classController.addClass(req, resp);//添加班级信息页面
        else if ("/Administrator/classManager/addClass/modifyNow.do".equals(path))classController.modifyAddClassNow(req, resp);//添加班级信息后台写入
        else if ("/Administrator/courses.do".equals(path))classController.courseManager(req,resp);//管理员课程管理页面
        else if ("/Administrator/courses/update.do".equals(path))classController.updateCourseName(req,resp);//课程信息修改页面
        else if ("/Administrator/courses/update/modifyNow.do".equals(path))classController.modifyCourseNow(req,resp);//课程信息修改后台
        else if ("/Administrator/courses/addCourse.do".equals(path))classController.addCourse(req,resp);//添加课程信息页面
        else if ("/Administrator/courses/add/modifyNow.do".equals(path))classController.modifyAddCourseNow(req,resp);//添加课程后台写入
        else if ("/Administrator/personStu.do".equals(path))perController.doStudent(req,resp);//学生管理主页
        else if ("/Administrator/personStu/updateIndex.do".equals(path))perController.goStu(req,resp);//跳转学生修改主页
        else if ("/Administrator/personStu/updateStu.do".equals(path))perController.updateStu(req,resp);//学生信息修改后台
        else if ("/Administrator/personStu/deleteStu.do".equals(path))perController.deleteStu(req,resp);//管理员删除学生
        else if ("/Administrator/personStu/addStu.do".equals(path))perController.addStu(req,resp);//管理员添加学生页
        else if ("/Administrator/personStu/addDoingStu.do".equals(path))perController.addDoingStu(req,resp);//管理员添加学生后台
        else if ("/Administrator/personTea.do".equals(path))perController.doTeacher(req,resp);//教师管理主页
        else if ("/Administrator/personTea/upIndex.do".equals(path))perController.upIndex(req,resp);//跳转教师修改主页
        else if ("/Administrator/personTea/upDoing.do".equals(path))perController.upTeach(req,resp);//跳转教师修改后台
        else if ("/Administrator/personTea/addTea.do".equals(path))perController.addTeacher(req,resp);//添加教师
        else if ("/Administrator/task.do".equals(path))taskController.show(req,resp);//教师管理主页
        else if ("/Administrator/task/delete.do".equals(path))taskController.delete(req,resp);//教师课程管理删除
        else if ("/Administrator/task/add.do".equals(path))taskController.add(req,resp);//教师课程管理添加
    }

    private void out(HttpServletResponse response)throws IOException,ServletException {
        response.getWriter().println("<body style=\"display: flex;justify-content: center;align-items: center\">\n" +
                "<h1 style=\"color:red\">无查阅授权：：<h1>\n" +
                "<a href=\"/index.jsp\">点击返回首页</a> "+
                "</body>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }


}
